package com.example.service;


import com.example.entity.Params;
import com.example.entity.Pet;
import com.example.mapper.PetMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PetService {
    @Autowired
    private PetMapper petMapper;

    public PageInfo<Pet> findBySearch(Params params) {
        PageHelper.startPage(params.getPageNum(), params.getPageSize());


        List<Pet> list = petMapper.findBySearch(params);
        return PageInfo.of(list);
    }

    public void add(Pet pet) {
        petMapper.add(pet);
    }

    public void update(Pet pet) {
        petMapper.update(pet);
    }

    public List<Pet> findAll() {
        return petMapper.findAll();
    }

    public void delete(Integer id) {

        petMapper.deleteById(id);
    }
}
